package lucene.search
{
	public class DefaultSimilarity extends Similarity
	{
		public function DefaultSimilarity()
		{
			super(this);
		}
		
	    override public function lengthNorm(fieldName:String, numTerms:int):Number
	    {
	        if (numTerms == 0) {
	            return 1E10;
	        }
	
	        return 1.0/Math.sqrt(numTerms);
	    }
	    
		override public function queryNorm(sumOfSquaredWeights:Number):Number
		{
		    return 1.0/Math.sqrt(sumOfSquaredWeights);
		}
		
		override public function tf(freq:Number):Number
		{
		    return Math.sqrt(freq);
		}
		
	    override public function sloppyFreq(distance:int):Number
	    {
	        return 1.0/(distance + 1);
	    }
	    
		override public function idfFreq(docFreq:int, numDocs:int):Number
		{
		    return Math.log(numDocs/(docFreq+1)) + 1.0;
		}
		
		override public function coord(overlap:int, maxOverlap:int):Number
		{
		    return overlap/maxOverlap;
		}
		
	}
}